package com.jyniubi.core.controller.admin;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jyniubi.base.result.R;
import com.jyniubi.core.pojo.entity.UserLoginRecord;
import com.jyniubi.core.service.UserLoginRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户登录记录表 前端控制器
 * </p>
 *
 * @author jyzhang
 * @since 2024-04-27
 */
@Api(tags = "用户登录记录模块")
@RestController

@RequestMapping("/admin/core/userLoginRecord")
public class AdminUserLoginRecordController {
    @Resource
    private UserLoginRecordService userLoginRecordService;
    @ApiOperation("查看用户最近的10条登录记录")
    @GetMapping("/getById/{userInfoId}")
    public R getById(@PathVariable("userInfoId") String userInfoId){
        List<UserLoginRecord> list = userLoginRecordService.list(Wrappers.lambdaQuery(UserLoginRecord.class).
                eq(UserLoginRecord::getUserId, userInfoId).
                orderByDesc(UserLoginRecord::getCreateTime).
                last("limit 10"));
        return R.ok().data("items",list);
    }
}

